package com.flyou.ccnucenter.ui.activity.henuBeside.lostFind;

import com.daimajia.slider.library.Animations.DescriptionAnimation;
import com.daimajia.slider.library.SliderLayout;
import com.daimajia.slider.library.SliderTypes.BaseSliderView;
import com.daimajia.slider.library.SliderTypes.TextSliderView;
import com.flyou.ccnucenter.R;
import com.flyou.ccnucenter.domain.Image;
import com.flyou.ccnucenter.ui.activity.BaseActivity1;
import com.flyou.ccnucenter.utils.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;

public class LostAndFoundActivity extends BaseActivity1 {
    private SliderLayout sliderLayout;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_lost_and_found);
        sliderLayout = (SliderLayout) findViewById(R.id.slider);
        //        轮播图切换方式
        sliderLayout.setPresetTransformer(SliderLayout.Transformer.Background2Foreground);
//        轮播图下面标志圆点的位置
        sliderLayout.setPresetIndicator(SliderLayout.PresetIndicators.Right_Bottom);
//        切换动画
        sliderLayout.setCustomAnimation(new DescriptionAnimation());
//        切换时间
        sliderLayout.startAutoCycle(0, 4000, true);
    }

    @Override
    protected void initDate() {
        String bannerImages = (String) SPUtils.get(LostAndFoundActivity.this, "bannerImages", "");
        Image image = toObj(bannerImages, new TypeToken<Image>() {
        }.getType());
        setBannerADapter(image);
    }

    @Override
    protected void setListener() {

    }


    public void setBannerADapter(Image response) {
        List<Image.ImagesEntity> images = response.getImages();
        for (int i = 0; i < images.size(); i++) {
            TextSliderView textSliderView = new TextSliderView(this);
            // initialize a SliderLayout
            textSliderView
                    .description(images.get(i).getImageDesc())
                    .image(images.get(i).getImageUrl())
                    .setScaleType(BaseSliderView.ScaleType.Fit)
            ;
//            //           增加其他信息
//            textSliderView.bundle(new Bundle());
//            textSliderView.getBundle()
//                    .putString("extra", images.get(i).getImageDesc());

          sliderLayout.addSlider(textSliderView);
        }
    }
}
